package com.hdoit.kylin.logical.baseInfo.dao.impl;

import java.util.List;
import org.springframework.stereotype.Component;
import com.hdoit.kylin.logical.baseInfo.dao.IMoneyTypeDao;
import com.hdoit.kylin.logical.baseInfo.model.MoneyType;
import com.hdoit.kylin.logical.group.model.Group;
import com.hdoit.kylin.logical.viewmodel.baseInfo.MoneyTypeSearch;
import com.tennetcn.common.dao.base.IFinderExpression;
import com.tennetcn.common.dao.base.impl.SuperDao;
import com.tennetcn.common.message.PagerModel;
import com.tennetcn.common.utils.FinderExpressionFactory;

@Component
public class MoneyTypeDaoImpl extends SuperDao<MoneyType> implements IMoneyTypeDao {

	@Override
	public List<MoneyType> queryList(String groupId) {
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.select("moneyType.*")
						.from(MoneyType.class,"moneyType")
						.andWhere("moneyType.groupId=#{groupId}")
						.setParam("groupId",groupId);
						
		return queryList(finderExpression);
	}

	@Override
	public List<MoneyType> queryList(MoneyTypeSearch search, PagerModel pagerModel) {
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.select("moneyType.*,group_info.groupName as groupName")
						.from(MoneyType.class,"moneyType")
						.leftJoin(Group.class,"group_info")
						.on("moneyType.groupId","group_info.groupId");
		return queryList(finderExpression,search,pagerModel);
	}

}
